function selectQyxxTwo(tplcode){
	var title = "请选择单位";
	if(tplcode.indexOf("csdlwj")>=0 || tplcode.indexOf("jzfqwczzpf")>=0 || tplcode.indexOf("jzfqwczzxn")>=0){
		title ="请选择施工单位";
	}else if(tplcode.indexOf("csdllszysp")>=0){
		title ="请选择临时占用单位";
	}
	ExtElQyxxTwoWin({id: 'selectQyxxTwo', title: title, w: 550, h: 400, tplcode: tplcode});
}

function ExtElQyxxTwoWin(f) {
  var w = 350;
  var h = 160;
  if (f.w) w = f.w;
  if (f.h) h = f.h;
  var qyxxTwoGrid = new Ext.ux.grid.YwGrid({
    region: 'center',
    layout: 'fit',
    tplcode: f.tplcode,
    margins: '1 1 1 1',
    needSelect4CsdlwjTbar:true,
    url: '/yw-com-qyxx-two!dataList.action?templateCodeTwo='+f.tplcode,
    keyField: 'id',
    defaultSortField: 'sqrqTwo',
    structure: [{
      name: 'id',
      hidden: true
    },{
      name: 'phoneTwo',
      hidden: true
    },{
      name: 'telTwo',
      hidden: true
    },{
      name: 'aqfzrTwo',
      hidden: true
    },{
      name: 'lxrTwo',
      hidden: true
    },{
      name: 'addressTwo',
      hidden: true
    },{
      name: 'templateCodeTwo',
      hidden: true
    },{
      name: 'xmjlTelTwo',
      hidden: true
    },{
      name: 'xmjlTwo',
      hidden: true
    },{
      name: 'sqdwTwo',
      header: '企业名称'
    },{
      name: 'sqrqTwo',
      header: '申请日期',
      width: 17
    }]
  });
  
  var store = qyxxTwoGrid.store;
  var toolbar = qyxxTwoGrid.toolbar;
  store.on('beforeload', function(){
    store.baseParams = {
      sqdwTwo: toolbar.search_sqdw.getValue()
    };
  }, this);
  
  new Ext.Window({
    id        : f.id,
    title     : f.title,
    width     : w,
    height    : h,
    iconCls   : 'icon_title',
    layout    : 'fit',
    modal     : true,
    plain     : true,
    resizeable: false,
    items     : [qyxxTwoGrid]
  }).show();
}

function selectQyxxTwoCallback(params){
	
	if(params.r.get('templateCodeTwo').indexOf("csdlwj")>=0){//道路挖掘
		try{
			if(document.forms[0].SR_DLWJSQB_QYBH_TWO && params.r.get('id'))
				document.forms[0].SR_DLWJSQB_QYBH_TWO.value = params.r.get('id');
			if(document.forms[0].SR_DLWJSQB_SGDW && params.r.get('sqdwTwo'))
				document.forms[0].SR_DLWJSQB_SGDW.value = params.r.get('sqdwTwo');
			if(document.forms[0].SR_DLWJSQB_SGDW_ADDRESS && params.r.get('addressTwo'))
				document.forms[0].SR_DLWJSQB_SGDW_ADDRESS.value = params.r.get('addressTwo');
			if(document.forms[0].SR_DLWJSQB_AQFZR && params.r.get('aqfzrTwo'))
				document.forms[0].SR_DLWJSQB_AQFZR.value = params.r.get('aqfzrTwo');
			if(document.forms[0].SR_DLWJSQB_SGDW_TEL && params.r.get('telTwo'))
				document.forms[0].SR_DLWJSQB_SGDW_TEL.value = params.r.get('telTwo');
			if(document.forms[0].SR_DLWJSQB_SGDW_LXR && params.r.get('lxrTwo'))
				document.forms[0].SR_DLWJSQB_SGDW_LXR.value = params.r.get('lxrTwo');
		}catch(e){}
	}else if(params.r.get('templateCodeTwo').indexOf("csdllszysp")>=0){//道路占用
		try{
			if(document.forms[0].SR_DLZYSQB_QYBH_TWO && params.r.get('id'))
				document.forms[0].SR_DLZYSQB_QYBH_TWO.value = params.r.get('id');
			if(document.forms[0].SR_DLZYSQB_ZYDW && params.r.get('sqdwTwo'))
				document.forms[0].SR_DLZYSQB_ZYDW.value = params.r.get('sqdwTwo');
			if(document.forms[0].SR_DLZYSQB_ZYDW_ADDRESS && params.r.get('addressTwo'))
				document.forms[0].SR_DLZYSQB_ZYDW_ADDRESS.value = params.r.get('addressTwo');
			if(document.forms[0].SR_DLZYSQB_AQFZR && params.r.get('aqfzrTwo'))
				document.forms[0].SR_DLZYSQB_AQFZR.value = params.r.get('aqfzrTwo');
			if(document.forms[0].SR_DLZYSQB_ZYDW_TEL && params.r.get('telTwo'))
				document.forms[0].SR_DLZYSQB_ZYDW_TEL.value = params.r.get('telTwo');
			if(document.forms[0].SR_DLZYSQB_ZYDW_LXR && params.r.get('lxrTwo'))
				document.forms[0].SR_DLZYSQB_ZYDW_LXR.value = params.r.get('lxrTwo');
		}catch(e){}
	}else if(params.r.get('templateCodeTwo').indexOf("jzfqwczzpf")>=0 || params.r.get('templateCodeTwo').indexOf("jzfqwczzxn")>=0){//排放  消纳
		try{
			if(document.forms[0].qybhTwo && params.r.get('id'))
				document.forms[0].qybhTwo.value = params.r.get('id');
			if(document.forms[0].sgdwXmjl && params.r.get('xmjlTwo'))
				document.forms[0].sgdwXmjl.value = params.r.get('xmjlTwo');
			if(document.forms[0].sgdwGz && params.r.get('sqdwTwo'))
				document.forms[0].sgdwGz.value = params.r.get('sqdwTwo');
			if(document.forms[0].sgdwXmjlLxdh && params.r.get('xmjlTelTwo'))
				document.forms[0].sgdwXmjlLxdh.value = params.r.get('xmjlTelTwo');
			if(document.forms[0].sgdwLxr && params.r.get('lxrTwo'))
				document.forms[0].sgdwLxr.value = params.r.get('lxrTwo');
			if(document.forms[0].sgdwLxrLxdh && params.r.get('telTwo'))
				document.forms[0].sgdwLxrLxdh.value = params.r.get('telTwo');
		}catch(e){}
	}
}